package cn.edu.fzu.homemaking.wallet.config;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import lombok.SneakyThrows;

@Component
public class DateConverter implements Converter<String, Date> {

    @SneakyThrows
    @Override
    public Date convert(String date) {
        if (StringUtils.isBlank(date)) {
            return null;
        }
        return DateUtils.parseDate(date, "yyyy-MM-dd");

    }
}
